#include <iostream>
using namespace std;

int GetMonthDay(int year, int month)
{
    static int array[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
    int day = array[month];
    if (month == 2
        && (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)))
    {
        ++day;
    }
    return day;
}

int main() {
    int year, month, day;
    cin >> year >> month >> day;
    int countDay = 0;
    for (int i = 1; i < month; ++i)
    {
        countDay += GetMonthDay(year, i);
    }
    countDay += day;
    cout << countDay << endl;
    return 0;
}